<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>推广URL列表</title>
    <!--{include file='comm/icheck.tpl'}-->
    <!--{include file='comm/comm_editor.tpl'}-->
</head>
<body>


<div class="container">
 
        <div class="comm_content">

            <div  class="search-box">
                <form id="searchForm" class="form-inline" onsubmit="return false;">
                    <div style="position:relative">

                        <span>
                        	<span style='width:70px;text-align:right'>
                             渠道KEY1：
                            </span>
                            <select class="form-control input-sm" name='key1' id='key1'>
                            	<option value='0'>请选择</option>
                            	<!--{foreach from=$item_array item=item_array_info}-->
                            		<option value="<!--{$item_array_info.itemID}-->"><!--{$item_array_info.itemName}--></option>
                            	<!--{/foreach}--> 
                            </select>
                        </span>
                        <span>
                        	<span style='width:20px;text-align:right'>
                        	 KEY2:
                        	</span>
                        	<input id="key2" class="form-control input-sm"  type="text" name="key2" value="" style="width:140px">                     	
                        </span>
                        <span>
                        	<span style='width:20px;text-align:right'>
                        	 KEY3:
                        	</span>
                        	<input id="key3" class="form-control input-sm"  type="text" name="key3" value="" style="width:140px">                              	             	
                        </span>   
                        <span>
                        	<span style='width:70px;text-align:right'>
                            推广URL：
                            </span>
                            <input id="tuiguang_url" name='url' class="form-control input-sm"  type="text"  value="" style="width:440px">
                        </span>
                        <span >
                            <input type="button" class="btn btn-primary" value="查询" onclick="coupon.search();">&nbsp;&nbsp;
                            <input type="button" class="btn btn-warning btn-sm" value="重置" onclick="coupon.cz();">&nbsp;&nbsp;
                        </span>                        
                    </div>
                </form>
            </div>

            <table id="flex" style="display:none"></table>

        </div>

</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/system/promote.ajax?operFlg=1",
        dataType: "json",
        colModel : [
        	{display: "操作", width : 50, align: 'center'},
        	{display: "完整URL", width : 500, align: 'left'},
        	{display: "渠道KEY1", width : 70, align: 'center'},
            {display: "KEY2", width : 70, align: 'center'},
            {display: "KEY3", width : 70, align : 'left' },
            {display: "推广URL", width : 300, align: 'left'},
            {display: "创建人", width : 70, align: 'center'},
            {display: "创建日期", width : 150, align: 'center'},
            {display: "开始日期", width : 130, align: 'center'},
            {display: "结束日期", width : 130, align: 'center'},

        ],
	    buttons : [
	        {name: "添加", bclass: "add", onpress : "coupon.add"},
	        {separator: true},
	        {name: "删除", bclass: "delete", onpress : "coupon.reset"},
	        {separator: true},
	
	
	    ],        
        sortname: "promoteID",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true
    });

    var coupon = {

        //查询
        search : function (){
   		 	var dt = $("#searchForm").serializeArray();
      		$("#flex").flexOptions({newp: 1, params: dt}).flexReload();
        },
        cz : function(){
           		$("#key1").val(0);   //设置Select索引值为1的项选中
            	$('#key2').val('');
            	$('#key3').val('');
            	$('#tuiguang_url').val('');

            	var dt = $("#searchForm").serializeArray();
            	$("#flex").flexOptions({newp: 1, params: dt}).flexReload();           		
        },
        add : function(){
        	E.open("/quanliadmin/app/system/promote.pscript?operFlg=2", "" , {height: 340,width: 980, top: 100, left: 200});
        },

        //删除推广
        reset : function(){
        	var selected_count = $('.trSelected',flex).length;
	        if (selected_count==0) {
	            E.alert("请选择要删除的数据");
	            return;
	        }
        	E.confirm("确定删除推广吗","coupon.trueRest");
     	
        	
		},
		trueRest : function(){
			var selected_count = $('.trSelected',flex).length;
	        if (selected_count==0) {
	            E.alert("请选择要删除的数据");
	            return;
	        }
	        var selected_count = $('.trSelected',flex).length;
	        if (selected_count==0) {
	            E.alert("请选择要删除的数据");
	            return;
	        }
	
	        var tempArr = new Array(); 
	        for(var i=0; i<selected_count; i++){
	            var templateIDStr = $('.trSelected',flex).eq(i).attr('id');
	            var templateIDStr = templateIDStr.substr(3);
	            tempArr.push(templateIDStr);
	        }

			$.ajax({
	            url: "/invokingAjax-backend/system/promote.ajax?operFlg=3",
	            data: {
	            	promoteID : tempArr 

	            },
	            type: "POST",
	            success: function(data){

					if(data ==1){
						E.alert('推广url已删除',2);
						coupon.search();
						return false;
					}

					
	            }            
	        });   		
		
		},
		//判断推广url是否成功
		yz : function(key){
			
			E.open("/quanliadmin/app/system/promote.pscript?operFlg=3&key="+key, "" , {height: 540,width: 980, top: 100, left: 200});

			
		}
    };


</script>

</body>
</html>